#include  <cstdio>
#include  <cstring>

int cmp(char *a, char *b)
{
	int sum = 0, la = strlen(a), lb = strlen(b);
	for( int i = 0, j = 0; i < la && j < lb ; ++i, ++j )
		if( a[i] == b[j] )
			sum++;

	return sum;
}

int gcd(int a, int b)
{
	while( true )
	{
		if( a < b )
		{
			b %= a;
			if( b == 0 )
				return a;
		} else
		{
			a %= b;
			if( a == 0 )
				return b;
		}
	}
}

int main(int argc, char *argv[])
{
	char a[30],b[30];
	while( scanf("%s",a) && a[0] != '-' )
	{
		scanf("%s",b);
		int la = strlen(a), lb = strlen(b);
		int max = cmp(a,b),res;
		for( int i = 1 ; i < la ; ++i )
		{
			res = cmp(a+i,b);
			max = res > max ? res : max;
		}
		for( int i = 1 ; i < lb ; ++i )
		{
			res = cmp(a,b+i);
			max = res > max ? res : max;
		}
		max *= 2;
		if(max == 0)
			printf("appx(%s,%s) = 0\n",a,b);
		else if(max == 2)
			printf("appx(%s,%s) = 1\n",a,b);
		else
		{
			int g = gcd(max,la+lb);
			printf("appx(%s,%s) = %d/%d\n",a,b,max/g,(la+lb)/g);
		}
	}
}
